package com.yunji.order.business.delay;

import com.yunji.order.business.OrderBusiness;
import com.yunji.order.domain.OrderDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.business.pattern
 * @Title: OrderDeliveredHandler
 * @Description: 订单交付处理
 * <p>
 * History:
 * Date						Version			Author			Summary
 * ========================================================================
 * 2024-04-20 20:10:25		V1.0			HuaAo		新建类
 */
@Component
public class DeliveredHandler implements BusinessHandler {
    private static final Logger logs = LoggerFactory.getLogger(DeliveredHandler.class);

    @Resource
    private OrderBusiness business;

    @Override
    public void process(OrderDO order) {
        logs.info("【延时订单发货】订单信息:{}", order);
        Long orderId = order.getOrderId();
        try {
            business.orderDeliveries(order);
            logs.info("【延时订单发货】订单{}发货成功", orderId);
        } catch (Exception e) {
            logs.error("【延时订单发货】处理失败{}", orderId, e);
        }
    }
}